package eu.irreality.dai.gameplay.states;

import eu.irreality.dai.gameplay.actions.Action;
import eu.irreality.dai.util.Direction;
import eu.irreality.dai.util.exceptions.GameException;
import eu.irreality.dai.util.exceptions.InternalErrorException;

public class WhichDirectionState extends GameState
{

    public interface DirectionToAction
    {
	public Action getAction(Direction d);
    }

    private DirectionToAction d2a;

    public WhichDirectionState(DirectionToAction d2a)
    {
	this.d2a = d2a;
    }

    public void executeAction(Direction d) throws InternalErrorException,
	    GameException
    {
	this.d2a.getAction(d).execute();
    }

    // TODO: from here, probably legacy if we remove the requirement of
    // registering states in the manager

    private static WhichDirectionState whichInstance;

    static
    {
	whichInstance = new WhichDirectionState();
	GameStateManager.register("WhichDirectionState", whichInstance);
    }

    private WhichDirectionState()
    {
    }

}
